package guoanmaker.operator.business.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.service.AppraiseService;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * @ClassName: OperatorAppraoseController
 * @Description: 后台订单查询
 * @author xiaoqiang
 * @date 2017年12月18日 下午4:11:12
 *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_ORDERFORM)
public class OperatorAppraoseController {

	@Resource
	private AppraiseService appraiseService;

	/**
	 * 
	 * @Title: queryAppraiseByParameters
	 * @Description: 查询订单评价信息
	 * @param page 页码
	 * @param pageSize 页面数据数
	 * @param orderNumber 订单编号
	 * @param appraiseKind 评价类型(好评：中评：差评 ) 默认全部
	 * @param appraisePhone 评价人手机号
	 * @param goodNumber 商品编号
	 * @param shopName 商户名称
	 * @param beginDate 开始日期
	 * @param endDate 结束日期
	 * @return AjaxJson 
	 * @throws
	 */
	@ApiOperation(value = "查询订单评价信息", notes = "查询订单评价信息")
	@PostMapping("/queryAppraiseByParameters")
	public AjaxJson queryAppraiseByParameters(
			@RequestParam(value = "page", required = true, defaultValue = "1") int page,
			@RequestParam(value = "pageSize", required = true, defaultValue = "10") int pageSize,
			@RequestParam(value = "orderNumber", required = false) String orderNumber,
			@RequestParam(value = "appraiseKind", required = false) String appraiseKind,
			@RequestParam(value = "appraisePhone", required = false) String appraisePhone,
			@RequestParam(value = "goodNumber", required = false) String goodNumber,
			@RequestParam(value = "shopName", required = false) String shopName,
			@RequestParam(value = "beginDate", required = false) String beginDate,
			@RequestParam(value = "endDate", required = false) String endDate) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功")
					.setData(appraiseService.findAppraiseByParameters(page, pageSize, orderNumber, appraiseKind,
							appraisePhone, goodNumber, shopName, beginDate, endDate));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData(null);
		}
		return ajaxJson;
	}
	/**
	 * 
	 * @Title: setVisible
	 * @Description: 更新评论是否可见
	 * @param ids 评论 id 若传入多个值用","隔开
	 * @param isShow 是否展示 1 展示 2 隐藏
	 * @return AjaxJson 
	 * @throws
	 */
	@ApiOperation(value = "更新评论是否可见", notes = "更新评论是否可见")
	@PostMapping("/setVisible")
	public AjaxJson setVisible(@RequestParam(value = "ids") String ids, @RequestParam(value = "isShow") String isShow) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			String[] id = ids.split(",");
			appraiseService.setVisible(id, isShow);
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData("更新成功").setData(null);
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}

}
